﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SIMCFachadaNegocio;
using SIMCObjetoNegocio;

namespace SIMCPresenter
{

    public interface IConsultarAtributosView : IViewBase
    {
        event EventHandler<SearchEventArgs<int>> Buscar;

        string AtributoSeleccionado { get; set; }
        List<ClasificacionPersonas> Atributo { get; set; }
    }

    public class ConsultarAtributosPresenter : PresenterBase
    {
        private IConsultarAtributosView mView;
        private FachadaPersona m_FachadaPersona;

        public ConsultarAtributosPresenter(IConsultarAtributosView view)
            : base (view)
        {
            this.mView = view;
            m_FachadaPersona = new FachadaPersona();
            this.Initialize();
        }

        private void Initialize()
        {
            this.mView.Buscar += new EventHandler<SearchEventArgs<int>>(mView_Buscar);
        }

        private void mView_Buscar(object sender, SearchEventArgs<int> e)
        {
            try
            {
                mView.Atributo = m_FachadaPersona.BuscarListaAtributo(e.Element, mView.AtributoSeleccionado);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                throw;
            }
        }
    }
}
